#define _CRT_SECURE_NO_WARNINGS 1

int binarySearch(int* nums, int numsSize, int target) {
    int left = 0, right = numsSize - 1, mid;

    while (left <= right) {
        mid = (right - left) / 2 + left;
        if (nums[mid] < target) {
            left = mid + 1;
        }
        else {
            right = mid - 1;
        }

    }

    return left;
}

int searchInsert(int* nums, int numsSize, int target) {
    return binarySearch(nums, numsSize, target);
}

